//
//  UpdateUserDataViewController.m
//  XinKaiFa55like
//
//  Created by junseek on 2017/1/17.
//  Copyright © 2017年 55like lj. All rights reserved.
//

#import "UpdateUserDataViewController.h"
#import "AlertZKView.h"
#import <ZYQAssetPickerController.h>
#import "SellSelectTypeViewController.h"
#import "MyBusinessCardWXData.h"

@interface UpdateUserDataViewController ()<UITextFieldDelegate,AlertZKViewDelegate,ZYQAssetPickerControllerDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,UITextViewDelegate>{
    UIScrollView *scrollBG;
    UIImageView *imageLogo;
    UITextField *txtName;
    UITextField *txtWx;
//    UITextField *txtBM;
    UITextField *txtCode;
    UITextField *txtPhone;
    UITextView *txtContent;
    UITextField * txtEmail;
    
    UIImage *logoTemp;
    
    AlertZKView *alertZk;
    UIImagePickerController *ipc;
    
    NSDictionary *dicUserOld;
    NSArray *arraydepartment;
    NSDictionary *selectType;
    
    UIImageView * userLogoWx;
    BOOL boolHiddenBackPrompt;//返回提示
    NSDictionary *dicWxData;
}

@end

@implementation UpdateUserDataViewController

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBarHidden = YES;
    
    
    KKNavigationController *kNav=(KKNavigationController *)self.navigationController;
    kNav.canDragBack=NO;
    
    //注册监听键盘事件
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyboardDidShow:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleKeyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
    
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    
    
    KKNavigationController *kNav=(KKNavigationController *)self.navigationController;
    kNav.canDragBack=YES;
    
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self rightButton:@"提交" image:nil sel:@selector(rightButtonClicked)];
    
    
    scrollBG=[[UIScrollView alloc] initWithFrame:CGRectMake(0, kTopHeight, kScreenWidth, kContentHeight)];
    scrollBG.backgroundColor=rgbGray;
    [self.view addSubview:scrollBG];
    
    NSInteger tempY=10;
    UIView *viewBG=[[UIView alloc] initWithFrame:CGRectMake(0, 10, kScreenWidth, 10)];
    viewBG.backgroundColor=[UIColor whiteColor];
    [scrollBG addSubview:viewBG];
    
    imageLogo=[RHMethods imageviewWithFrame:CGRectMake(kScreenWidth-60, tempY+10, 50, 50) defaultimage:@"loadImageBG"];
    [scrollBG addSubview:imageLogo];
    [[Utility Share] viewLayerRound:imageLogo borderWidth:0.5 borderColor:[UIColor clearColor]];
    
    
    [scrollBG addSubview:[RHMethods labelWithFrame:CGRectMake(10, tempY+25, 0, 20) font:fontTitle color:rgbTitleColor text:@"头像"]];
    
    UIButton *btnLogo=[RHMethods buttonWithFrame:CGRectMake(0, tempY, kScreenWidth, 70) title:nil image:nil bgimage:nil];
    [btnLogo addTarget:self action:@selector(updateLogoButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    [scrollBG addSubview:btnLogo];
    
    
    tempY+=70;
    [scrollBG addSubview:[RHMethods imageviewWithFrame:CGRectMake(0, tempY-0.5, kScreenWidth, 0.5) defaultimage:@"userLine"]];
    UIView *viewLine=[[UIView alloc] initWithFrame:CGRectMake(0, tempY, kScreenWidth, 10)];
    viewLine.backgroundColor=rgbGray;
    [scrollBG addSubview:viewLine];
    tempY+=10;
    
    [scrollBG addSubview:[RHMethods labelWithFrame:CGRectMake(10, tempY, 0, 44) font:fontTitle color:rgbTitleColor text:@"邮箱"]];
    txtEmail=[RHMethods textFieldlWithFrame:CGRectMake(100, tempY, kScreenWidth-110, 44) font:fontTitle color:rgbTitleColor placeholder:@"请输入" text:@""];
    [txtEmail setDelegate:self];
    [scrollBG addSubview:txtEmail];
    
    tempY+=44;
    [scrollBG addSubview:[RHMethods imageviewWithFrame:CGRectMake(0, tempY-0.5, kScreenWidth, 0.5) defaultimage:@"userLine"]];
    UIView *viewLine2=[[UIView alloc] initWithFrame:CGRectMake(0, tempY, kScreenWidth, 10)];
    viewLine2.backgroundColor=rgbGray;
    [scrollBG addSubview:viewLine2];
    tempY+=10;
    
    [scrollBG addSubview:[RHMethods labelWithFrame:CGRectMake(10, tempY, 0, 44) font:fontTitle color:rgbTitleColor text:@"真实姓名"]];
    txtName=[RHMethods textFieldlWithFrame:CGRectMake(100, tempY, kScreenWidth-110, 44) font:fontTitle color:rgbTitleColor placeholder:@"请输入" text:@""];
    [txtName setDelegate:self];
    [scrollBG addSubview:txtName];
    
    tempY+=44;
    [scrollBG addSubview:[RHMethods imageviewWithFrame:CGRectMake(0, tempY-0.5, kScreenWidth, 0.5) defaultimage:@"userLine"]];
    
    //、、、
    [scrollBG addSubview:[RHMethods labelWithFrame:CGRectMake(10, tempY, 0, 44) font:fontTitle color:rgbTitleColor text:@"微信"]];
    txtWx=[RHMethods textFieldlWithFrame:CGRectMake(100, tempY, kScreenWidth-145, 44) font:fontTitle color:rgbTitleColor placeholder:@"" text:@""];
    [txtWx setDelegate:self];
    txtWx.userInteractionEnabled=NO;
    [scrollBG addSubview:txtWx];
    userLogoWx=[RHMethods imageviewWithFrame:CGRectMake(kScreenWidth-45, tempY, 20, 44) defaultimage:@"ewmIcon070116" contentMode:UIViewContentModeCenter];
    userLogoWx.userInteractionEnabled=NO;
    userLogoWx.tag=102;
    [scrollBG addSubview:userLogoWx];
    UIButton *btnWX=[RHMethods buttonWithFrame:CGRectMake(0, tempY, kScreenWidth, 44) title:nil image:@"Righticon070116" bgimage:nil];
    [btnWX setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
    [btnWX setContentEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 10)];
    [btnWX addTarget:self action:@selector(WXuttonClicked) forControlEvents:UIControlEventTouchUpInside];
    [scrollBG addSubview:btnWX];
    
    tempY+=44;
    
//    //、、、
//    [scrollBG addSubview:[RHMethods labelWithFrame:CGRectMake(10, tempY, 0, 44) font:fontTitle color:rgbTitleColor text:@"所属部门"]];
//    txtBM=[RHMethods textFieldlWithFrame:CGRectMake(100, tempY, kScreenWidth-125, 44) font:fontTitle color:rgbTitleColor placeholder:@"" text:@""];
//    [txtBM setDelegate:self];
//    txtBM.userInteractionEnabled=NO;
//    [scrollBG addSubview:txtBM];
//    UIButton *btnSex=[RHMethods buttonWithFrame:CGRectMake(0, tempY, kScreenWidth, 44) title:nil image:@"Righticon070116" bgimage:nil];
//    [btnSex setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
//    [btnSex setContentEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 10)];
//    [btnSex addTarget:self action:@selector(BMButtonClicked) forControlEvents:UIControlEventTouchUpInside];
//    [scrollBG addSubview:btnSex];
//    
//    tempY+=44;
    [scrollBG addSubview:[RHMethods imageviewWithFrame:CGRectMake(0, tempY-0.5, kScreenWidth, 0.5) defaultimage:@"userLine"]];
    
    
    ////
    [scrollBG addSubview:[RHMethods labelWithFrame:CGRectMake(10, tempY, 0, 44) font:fontTitle color:rgbTitleColor text:@"手机号"]];
    txtPhone=[RHMethods textFieldlWithFrame:CGRectMake(100, tempY, kScreenWidth-110, 44) font:fontTitle color:rgbTxtDeepGray placeholder:@"" text:@""];
    [txtPhone setEnabled:NO];
//    [txtPhone setKeyboardType:UIKeyboardTypePhonePad];
    [scrollBG addSubview:txtPhone];
    
    tempY+=44;
    if (![[Utility Share] userIsADD]) {
        ///渠道商版本不需要
        [scrollBG addSubview:[RHMethods imageviewWithFrame:CGRectMake(0, tempY-0.5, kScreenWidth, 0.5) defaultimage:@"userLine"]];
        ////
        [scrollBG addSubview:[RHMethods labelWithFrame:CGRectMake(10, tempY, 0, 44) font:fontTitle color:rgbTitleColor text:@"工号"]];
        txtCode=[RHMethods textFieldlWithFrame:CGRectMake(100, tempY, kScreenWidth-110, 44) font:fontTitle color:rgbTitleColor placeholder:@"请输入" text:@""];
        [txtCode setDelegate:self];
        //    [txtCode setKeyboardType:UIKeyboardTypePhonePad];
        [scrollBG addSubview:txtCode];
        
        tempY+=44;
        [scrollBG addSubview:[RHMethods imageviewWithFrame:CGRectMake(0, tempY-0.5, kScreenWidth, 0.5) defaultimage:@"userLine"]];
        UIView *viewLine3=[[UIView alloc] initWithFrame:CGRectMake(0, tempY, kScreenWidth, 10)];
        viewLine3.backgroundColor=rgbGray;
        [scrollBG addSubview:viewLine3];
        tempY+=10;
        UIView *viewBGtt=[RHMethods setTextViewWithFrame:CGRectMake(-1, tempY, kScreenWidth+2, 100) leftRightEdge:5 topBottomEdge:5 font:fontTitle color:rgbTitleColor placeholder:@"个性签名" delegate:self];
        viewBGtt.backgroundColor=[UIColor whiteColor];
        viewBGtt.layer.borderWidth=0.5;
        viewBGtt.layer.borderColor =[rgbLineColor CGColor];
        [scrollBG addSubview:viewBGtt];
        txtContent=(UITextView *)[viewBGtt viewWithTag:200];
        [txtContent setReturnKeyType:UIReturnKeyDone];
        tempY+=100;
        [txtCode setTextAlignment:NSTextAlignmentRight];

    }
    
    
    
    [txtName setTextAlignment:NSTextAlignmentRight];
    [txtEmail setTextAlignment:NSTextAlignmentRight];
    [txtPhone setTextAlignment:NSTextAlignmentRight];
    [txtWx setTextAlignment:NSTextAlignmentRight];
//    [txtBM setTextAlignment:NSTextAlignmentRight];
    
    viewBG.frameHeight=tempY-10;
    scrollBG.contentSize=CGSizeMake(0, tempY+20);
    
//    if (!self.otherInfo) {
//        [self refreshUserData];
//    }else{
        dicUserOld=self.otherInfo;
        [self refreUsersView];
//    }
}
-(void)refreshUserData{
    //    JSucenterindex
//    [NetEngine createGetAction_LJ_two:[NSString stringWithFormat:@"",[[Utility Share] userId],[[Utility Share] userToken]] onCompletion:^(id resData, BOOL isCache) {
//        if ([[resData valueForJSONStrKey:@"status"] isEqualToString:@"200"]) {
//            dicUserOld=[[resData objectForJSONKey:@"data"] objectForJSONKey:@"usreinfo"];
//            [self refreUsersView];
//        }else{
//            [SVProgressHUD showImage:nil status:[resData valueForJSONStrKey:@"info"]];
//            [super backButtonClicked:nil];
//        }
//    } onError:^(NSError *error) {
//        [SVProgressHUD showImage:nil status:alertErrorTxt];
//        [super backButtonClicked:nil];
//    }];
    
}
-(void)refreUsersView{
    [imageLogo imageWithURL:[dicUserOld valueForJSONStrKey:@"path"] useProgress:NO useActivity:NO];
//    txtBM.text=[dicUserOld valueForJSONStrKey:@"department"];
    txtName.text=[dicUserOld valueForJSONStrKey:@"realname"];
    selectType=@{@"name":[dicUserOld valueForJSONStrKey:@"department"]};
    if (![[Utility Share] userIsADD]) {
        txtCode.text=[dicUserOld valueForJSONStrKey:@"jobcodes"];
        txtContent.text=[dicUserOld valueForJSONStrKey:@"descr"];
        UIView *la = (UILabel *)[txtContent.superview viewWithTag:100];
        if (txtContent.text.length) {
            la.hidden = YES;
        }
    }
    txtEmail.text=[dicUserOld valueForJSONStrKey:@"email"];
    txtPhone.text=[dicUserOld valueForJSONStrKey:@"mobile"];
    [self popRefreshDataWX:dicUserOld];
}

#pragma mark selector
-(void)handleKeyboardDidShow:(NSNotification *)notification{
    NSDictionary *info = [notification userInfo];
    CGRect keyboardFrame;
    [[info objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&keyboardFrame];
    CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue].size;
    CGFloat distanceToMove = kbSize.height;
    DLog(@"---->动态键盘高度:%f",distanceToMove);
    
    [UIView animateWithDuration:0.3 animations:^{
        scrollBG.frameHeight=kContentHeight-distanceToMove;
        
    }];
}
- (void)handleKeyboardWillHide:(NSNotification *)notification
{
    [UIView animateWithDuration:0.3 animations:^{
        scrollBG.frameHeight=kContentHeight;
        
        
    }];
}//

#pragma mark button
-(void)rightButtonClicked{
    [self.view endEditing:YES];
    
    NSString *strName=txtName.text;
    NSString *strCode=txtCode.text;
//    NSString *strBM=txtBM.text;
    NSString *strContent=txtContent.text;
//    NSString *strPhone=txtPhone.text;
    NSString *strWx=txtWx.text;
    
    NSMutableDictionary *dicT=[NSMutableDictionary new];
    [dicT setValue:[[Utility Share] userToken] forKey:@"token"];
    [dicT setValue:[[Utility Share] userId] forKey:@"uid"];
    
    [dicT setValue:strName forKey:@"realname"];
//    [dicT setValue:strBM forKey:@"department"];
    [dicT setValue:strCode forKey:@"jobcodes"];
    [dicT setValue:strContent forKey:@"descr"];
    [dicT setValue:strWx forKey:@"wechat"];
//    [dicT setValue:strPhone forKey:@"tel"];
    [dicT setValue:txtEmail.text forKey:@"email"];
    NSMutableArray *arrayT=[NSMutableArray new];
    if (logoTemp) {//fileType==image
        NSData *data = [NSData dataWithData:UIImageJPEGRepresentation(logoTemp, 1.0)];
        [arrayT addObject:[NSDictionary dictionaryWithObjectsAndKeys:data,@"fileData",@"icon",@"fileKey",@"xxxx.jpg",@"fileName",@"image",@"fileType", nil]];
    }
    if ([dicWxData objectForKey:@"imageData"]) {
        NSData *data = [NSData dataWithData:UIImageJPEGRepresentation([dicWxData objectForKey:@"imageData"], 1.0)];
        [arrayT addObject:[NSDictionary dictionaryWithObjectsAndKeys:data,@"fileData",@"wxicon",@"fileKey",@"weixin.jpg",@"fileName",@"image",@"fileType", nil]];
    }
    
    [NetEngine uploadAllFileAction:XKFuserprofiles withParams:dicT fileArray:arrayT onCompletion:^(id resData, BOOL isCache) {
        if ([[resData valueForJSONStrKey:@"status"] isEqualToString:@"200"]) {
            [SVProgressHUD showSuccessWithStatus:[resData valueForJSONStrKey:@"info"]];
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [super backButtonClicked:nil];
            });
        }else{
            [SVProgressHUD showImage:nil status:[resData valueForJSONStrKey:@"info"]];
        }
    } onError:^(NSError *error) {
        [SVProgressHUD showImage:nil status:alertErrorTxt];
    } withMask:SVProgressHUDMaskTypeClear];
    
    

    
    
}
-(void)WXuttonClicked{
    //微信
    [self pushController:[MyBusinessCardWXData class] withInfo:@"" withTitle:@"微信号" withOther:dicWxData];
}
-(void)BMButtonClicked{
    [self.view endEditing:YES];
    if (!arraydepartment) {
        [NetEngine createGetAction:[NSString stringWithFormat:XKFuserdepartment,[[Utility Share] userId],[[Utility Share] userToken]] onCompletion:^(id resData, BOOL isCache) {
            if ([[resData valueForJSONStrKey:@"status"] isEqualToString:@"200"]) {
                arraydepartment=[[resData objectForJSONKey:@"data"] objectForJSONKey:@"list"];
                [self BMButtonClicked];
            }else{
                [SVProgressHUD showImage:nil status:[resData valueForJSONStrKey:@"info"]];
            }
        }];
    }else{
        [self pushController:[SellSelectTypeViewController class] withInfo:@"UpdateUserDataViewController" withTitle:@"选择部门" withOther:@{@"selectArray":@[[selectType valueForJSONStrKey:@"name"]],@"list":arraydepartment}];
    }
    
    
}
-(void)updateLogoButtonClicked{
    [self.view endEditing:YES];
    
    if (!alertZk) {
        alertZk =[[AlertZKView alloc]init];
    }
    alertZk.delegate=self;
    alertZk.userArray=[[NSArray alloc] initWithObjects:@"从相册选取",@"拍照", nil];
    alertZk.strTitle=@"添加图片";
    [alertZk show];
    
}
#pragma mark pop
-(void)popRefreshType:(NSDictionary *)dic{
    selectType=dic;
//    txtBM.text=[selectType valueForJSONStrKey:@"name"];
}
-(void)popRefreshDataWX:(NSDictionary *)dict{
    dicWxData=dict;
    txtWx.text=[dicWxData valueForJSONStrKey:@"wechat"];
    userLogoWx.hidden=NO;
    txtWx.frameWidth=kScreenWidth-150;
    if ([dicWxData objectForKey:@"imageData"]) {
//        userLogoWx.image=[dicWxData objectForKey:@"imageData"];
    }else if([[dicWxData valueForJSONStrKey:@"wxicon"] notEmptyOrNull]){
//        [userLogoWx imageWithURL:[dicWxData valueForJSONStrKey:@"wxicon"] useProgress:NO useActivity:NO];
    }else{
        userLogoWx.hidden=YES;
        txtWx.frameWidth=kScreenWidth-125;
    }

}
#pragma mark UITextFieldDelegate
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    [textField resignFirstResponder];
    
    return YES;
}

#pragma mark UITextViewDelegate
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
    if ([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
    }
    return YES;
}
-(void)textViewDidChange:(UITextView *)textView
{
    UIView *la = (UILabel *)[textView.superview viewWithTag:100];
    if (textView.text.length) {
        la.hidden = YES;
    }else{
        la.hidden = NO;
    }
}

#pragma mark AlertZKViewDelegate
-(void)AlertSelectZKView:(AlertZKView *)sview clickedButtonAtIndex:(NSInteger)aIndex{
    
    
    if (aIndex==0) {
        
        ZYQAssetPickerController *ZYQPicker = [[ZYQAssetPickerController alloc] init];
        ZYQPicker.maximumNumberOfSelection = 10;
        ZYQPicker.minimumNumberOfSelection=1;
        //        ZYQPicker.assetsFilter = [ALAssetsFilter allPhotos];
        ZYQPicker.showEmptyGroups=NO;
        ZYQPicker.showEditImageView=YES;
        ZYQPicker.delegate=self;
        //        SendNotify(ZKHiddenAudioPlayBtton, nil)
        [self presentViewController:ZYQPicker animated:YES completion:^{
            [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
        }];
        
        
    }else if (aIndex==1){
        NSString *mediaType = AVMediaTypeVideo;
        AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];
        if(authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied){
            NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
            NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
            [[Utility Share] showAccessPermissionsAlertViewMessage:[NSString stringWithFormat:@"‘%@’没有访问相机的权限，请前往【设置】允许‘%@’访问",app_Name,app_Name]];
            
            return;
        }
        
        if (!ipc) {
            ipc=[[UIImagePickerController alloc]init];
        }
        //判断当前相机是否可用
        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
        {// 打开相机
            ipc.sourceType = UIImagePickerControllerSourceTypeCamera;
            //设置是否可编辑
            ipc.allowsEditing = YES;
            ipc.delegate=self;
            //            SendNotify(ZKHiddenAudioPlayBtton, nil)
            //打开
            [self presentViewController:ipc animated:YES completion:^{
                [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault];
            }];
        }else
        {
            //如果不可用
            UIAlertView *alert=[[UIAlertView alloc]initWithTitle:nil message:@"设备不可用..." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil ];
            [alert show];
        }
        
    }
}


//设备协议
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    DLog(@"_____info:%@",info);
    //获得编辑过的图片
    UIImage *image=[info objectForKey:UIImagePickerControllerEditedImage];
    //处理图片
    logoTemp=[[Utility Share] imageWithImageSimple:image scaledToSize:CGSizeMake(600.0, 600.0)];
    // NSData *imgData=UIImageJPEGRepresentation(logo, 1.0);
    
    imageLogo.image=logoTemp;
    
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
    
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
    
}


#pragma mark - ZYQAssetPickerController Delegate
-(void)assetPickerController:(ZYQAssetPickerController *)picker didFinishPickingAssets:(NSArray *)assets{
    
}
-(void)assetPickerControllerDidMaximum:(ZYQAssetPickerController *)picker{
    [SVProgressHUD showImage:nil status:[NSString stringWithFormat:@"您只能选择%ld张",(long)picker.maximumNumberOfSelection]];
}
-(void)assetPickerController:(ZYQAssetPickerController *)picker cropImage:(UIImage *)cropImage forOriginalImage:(UIImage *)originalImage{
    //处理图片
    logoTemp=[[Utility Share] imageWithImageSimple:cropImage scaledToSize:CGSizeMake(600.0, 600.0)];
    imageLogo.image=logoTemp;
    
}
#pragma mark back
-(void)backButtonClicked:(id)sender{
    if (!boolHiddenBackPrompt ) {
        NSString *strName=txtName.text;
        NSString *strCode=txtCode.text;
        NSString *strContent=txtContent.text;
        NSString *strPhone=txtPhone.text;
        NSString *strWx=txtWx.text;
        
        if (logoTemp||
            ![strName isEqualToString:[dicUserOld valueForJSONStrKey:@"realname"]]||
            ![strCode isEqualToString:[dicUserOld valueForJSONStrKey:@"jobcodes"]]||
            ![strContent isEqualToString:[dicUserOld valueForJSONStrKey:@"descr"]]||
            ![strPhone isEqualToString:[dicUserOld valueForJSONStrKey:@"mobile"]]||
            ![strWx isEqualToString:[dicUserOld valueForJSONStrKey:@"wechat"]]||
            [dicWxData objectForKey:@"imageData"]) {
           
            [self backPromptOperation];
        }else{
            [super backButtonClicked:sender];
        }
        
        
    }else{
        [super backButtonClicked:sender];
    }
    
}

-(void)backPromptOperation{
    UIAlertView *alertBack=[[UIAlertView alloc] initWithTitle:nil message:@"您还有内容未保存哦！是否确定返回？" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    alertBack.tag=119;
    [alertBack show];
    
}

#pragma mark UIAlertViewDelegate
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (alertView.tag==119) {
        if (buttonIndex==1) {
            boolHiddenBackPrompt=YES;
            [self backButtonClicked:nil];
        }
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
